//
//  ZLPRankViewController.m
//  TangYi
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 赵连鹏. All rights reserved.
//

#import "ZLPRankViewController.h"
#import "ZLPRankModel.h"
#import <UIImageView+WebCache.h>
#import "ZLPRankTableViewCell.h"

@interface ZLPRankViewController ()<UITableViewDataSource, UITableViewDelegate>

@property(nonatomic, retain) UITableView *tableView;

@end

@implementation ZLPRankViewController

- (void)dealloc {
    [_tableView release];
    [_rankListArr release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"排行榜";
    
    [self createTableView];
    
    
    NSLog(@"%ld", self.rankListArr.count);

    
}

- (void)createTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 14) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    [_tableView release];
    
    [self.tableView registerClass:[ZLPRankTableViewCell class] forCellReuseIdentifier:@"reuse"];
    self.tableView.rowHeight = 90;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.rankListArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZLPRankTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"];
    ZLPRankModel *model = [[ZLPRankModel alloc] init];
    model = self.rankListArr[indexPath.row];
    cell.rankLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row + 1];
    cell.nameLabel.text = model.username;
    cell.part_in_rate.text = [NSString stringWithFormat:@"人气: %@", model.part_in_rate];
    [cell.avatar sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
